{template 'web/common/common'}
{template 'web/coupon/navbar'}
<link rel="stylesheet" type="text/css" href="../addons/kundian_farm/resource/css/style.css" />
<link rel="stylesheet" type="text/css" href="../addons/{php echo $_GPC['m']}/resource/swal/dist/sweetalert2.min.css" />
<div class="panel panel-success">
    <div class="panel-heading">
        <h3 class="panel-title">
            普通商城优惠券>编辑
        </h3>
    </div>
    <div class="panel-body">
        <form id="sign-form" class="form-horizontal" role="form" method="post" action="{url 'site/entry/coupon',array('m'=>'kundian_farm','op'=>'shop_coupon_save','version_id'=>$_GPC['version_id'])}" name="submit" style="padding: 20px 0;">
            <div class="form-group">
                <label class="col-sm-2 control-label">优惠券名称</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control"  name="coupon_name" value="{$list['coupon_name']}">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">优惠券类型</label>
                <div class="col-sm-8">
                    <label class="radio-inline">
                        <input type="radio" name="coupon_type" id="optionsRadios3" value="1" checked> 满减券
                    </label>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">最低消费金额（元）</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control"  name="low_cash_price" value="{$list['low_cash_price']}">
                    <span style="color: gray;font-size: 14px;">购物金额（不含运费）达到最低消费金额才可使用优惠券，无门槛优惠券请填0</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">优惠金额（元）</label>
                <div class="col-sm-4">
                    <input type="text" class="form-control"  name="coupon_price" value="{$list['coupon_price']}">
                    <span style="color: gray;font-size: 14px;">注：优惠券只能抵消商品金额，不能抵消运费</span>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">发放总数</label>
                <div class="col-sm-4">
                    <input type="number" class="form-control"  name="count" value="{$list['count']}">
                    <span style="color: gray;font-size: 14px;">注：优惠券总数量，没有不能领取或发放,-1为不限制张数</span>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">优惠券有效期</label>
                <div class="col-sm-8">
                    {if $list['expiry_date']==1}
                    <label class="radio-inline">
                        <input type="radio" name="expiry_date"  value="1" checked> 领取后N天内有效
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="expiry_date"  value="2"> 时间段
                    </label>
                    {else}
                    <label class="radio-inline">
                        <input type="radio" name="expiry_date"  value="1" > 领取后N天内有效
                    </label>
                    <label class="radio-inline">
                        <input type="radio" name="expiry_date"  value="2" checked> 时间段
                    </label>
                    {/if}
                </div>
            </div>
            {if $list['expiry_date']==1}
            <div class="form-group expiry_date" >
                <label class="col-sm-2 control-label">有效天数</label>
                <div class="col-sm-4">
                    <input type="number" class="form-control" min="1"  name="expiry_day" value="{$list['expiry_day']}">
                </div>
            </div>

            <div class="form-group expiry_day"  style="display: none;">
                <label class="col-sm-2 control-label">时间段</label>
                <div class="col-sm-4">
                    {php echo tpl_form_field_daterange('time', $value = array(), $time = false)}
                </div>
            </div>
            {else}
            <div class="form-group expiry_date" style="display: none;" >
                <label class="col-sm-2 control-label">有效天数</label>
                <div class="col-sm-4">
                    <input type="number" class="form-control" min="1"  name="expiry_day" value="{$list['expiry_day']}">
                </div>
            </div>

            <div class="form-group expiry_day" >
                <label class="col-sm-2 control-label">时间段</label>
                <div class="col-sm-4">
                    {php echo tpl_form_field_daterange('time',$time, $time = false)}
                </div>
            </div>
            {/if}

            <div class="form-group">
                <label class="col-sm-2 control-label">是否立即发放</label>
                <div class="col-sm-8">
                    {if $list['status']==1}
                    <input type="checkbox" checked class="js-switch" value="1" name="status">
                    {else}
                    <input type="checkbox" class="js-switch" name="status" value="1">
                    {/if}
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">排序</label>
                <div class="col-sm-4">
                    <input type="number" class="form-control"  name="rank" value="{$list['rank']}">
                </div>
            </div>
            <div class="form-group">

                <div class="col-sm-offset-2 col-sm-10">
                    <input type="hidden" name="id" value="{$list['id']}">
                    <input type="submit" name="submit" class="btn btn-primary">
                    <a class="btn btn-default" href="{url 'site/entry/coupon',array('m'=>'kundian_farm','op'=>'shop_coupon')}">返回</a>
                </div>
            </div>
        </form>
    </div>
</div>

<script>
    require(["../addons/{php echo $_GPC['m']}/resource/swal/dist/sweetalert2.min.js"],function(){
        $(function () {
            $("input[name='expiry_date']").change(function () {
                var value=$(this).val();
                if(value==1){
                    $(".expiry_day").hide();
                    $(".expiry_date").show();
                }else{
                    $(".expiry_day").show();
                    $(".expiry_date").hide();
                }
            })
        })

    })
</script>